/**
 * Created with CLion.
 * Description: 
 * User: loong
 * Date: 2023/12/19
 * Time: 20:56
 */

#ifndef CODSEEGMENT_NODE_H
#define CODSEEGMENT_NODE_H
#include <list>
#include <map>
#include <memory>
#include <string>

namespace Config {
    class Node;
    using NodeSPtr = std::shared_ptr<Node>;
    using NodeWPtr = std::weak_ptr<Node>;

    using NodeList  = std::list<NodeSPtr>;
    using NodeAttrs = std::map<std::string, std::string>;

    class NodeImpl;
    class Node
        : public std::enable_shared_from_this<Node>
    {
        friend class Doc;
    public:
        Node(std::string _key, std::string _value = "");

        Node();

        virtual ~Node() = default;

        virtual bool ToFile(const std::string & _file, const std::string & _indent = "\t");

        virtual std::string ToString(const std::string & _indent = "\t");

        virtual NodeList Children();

        virtual NodeSPtr AddChildren(const NodeList & _children);

        virtual NodeSPtr RemoveChildren(const NodeList & _children);

        virtual NodeList Child(const std::string & _name);

        virtual NodeSPtr RemoveChild(const std::string & _name);
#pragma region XML-USE
        virtual NodeAttrs Attrs();

        virtual std::string Attr(const std::string & _attr_name);

        virtual NodeSPtr AddAttr(const std::string & _attr, const std::string & _value);

        virtual NodeSPtr AddAttr(const NodeAttrs & _attr);

        virtual NodeSPtr RemoveAttr(const std::string & _attr);

        virtual NodeSPtr SetTagName(const std::string & _tag);

        virtual std::string TagName();

        virtual NodeSPtr SetValue(const std::string & _value);

        virtual std::string Value();
#pragma endregion

    private:
        std::shared_ptr<NodeImpl> node_impl_;
    };

}// namespace Config

#endif//CODSEEGMENT_NODE_H
